package hzau.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import hzau.pojo.Course;
import hzau.pojo.requestParams.CourseRegisterParam;
import hzau.result.Result;
import hzau.service.CourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@CrossOrigin
@RestController
@RequestMapping("course")
@Api(tags = "课程相关接口")
public class CourseController {
    @Autowired
    CourseService courseService;
    @PostMapping("register")
    @ApiOperation("新增课程")
    public Result register(@RequestBody CourseRegisterParam course){
        return courseService.register(course);
    }
    @PostMapping("delete")
    @ApiOperation("删除课程")
    public Result delete(Long id){
        return courseService.delete(id);
    }
    @PostMapping("update")
    @ApiOperation("更新课程信息")
    public Result update(Long courseId, @RequestBody CourseRegisterParam course){
        return courseService.update(courseId,course);
    }
    @GetMapping("getAll/{collegeId}/{pageNum}")
    @ApiOperation("获取学院所有课程")
    public Result getAll(@PathVariable("collegeId") Long collegeId,@PathVariable Integer pageNum){
        return courseService.getAll(collegeId,pageNum);
    }
    @GetMapping("getOne/{courseId}")
    @ApiOperation("查询一个课程信息")
    public Result getOne(@PathVariable  Long courseId){
        return courseService.getOne(courseId);
    }
    @PostMapping("alterCreateTeacher")
    @ApiOperation("修改出卷老师")
    public Result alterCreateTeacher(Long courseId,Long teacherId){
        return courseService.alterCreateTeacher(courseId,teacherId);

    }
    @PostMapping("alterReviewTeacher")
    @ApiOperation("修改评审老师")
    public Result alterReviewTeacher(Long courseId,Long teacherId){
        return courseService.alterReviewTeacher(courseId,teacherId);

    }
}
